package ui;

import java.awt.EventQueue;

import javax.swing.ButtonGroup;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JCheckBox;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JTextField;
import javax.swing.JLabel;

public class StartNode {

	private JFrame frame;
	private JTextField textField_file;
	private JFileChooser fileChooser; 
	private JButton btnSelezionaFile;
	private JButton btnStartNode;
	private JCheckBox chckbxAvviaNodoE,chckbxAvviaNodo;

public JCheckBox getCheckStartNode(){
	return this.chckbxAvviaNodo;
}
	
	public JCheckBox getCheckDiscovery(){
		return this.chckbxAvviaNodoE;
	}
	public JButton getSelectFileButton(){
		return this.btnSelezionaFile;
	}
	
	public JButton getStartNodeButton(){
		return this.btnStartNode;
	}
	
	public JFrame getFrame(){
		return this.frame;
	}

	public JTextField getFileField(){
		return this.textField_file;
	}
	
	public JFileChooser getChooser(){
		return this.fileChooser;
	}
	
	/**
	 * Create the application.
	 */
	public StartNode() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 521, 259);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		chckbxAvviaNodoE = new JCheckBox("Avvia nodo e discovery");
		chckbxAvviaNodoE.setBounds(33, 37, 217, 23);
		frame.getContentPane().add(chckbxAvviaNodoE);
		
		 chckbxAvviaNodo = new JCheckBox("Avvia nodo");
		chckbxAvviaNodo.setBounds(33, 72, 128, 23);
		frame.getContentPane().add(chckbxAvviaNodo);
		
		ButtonGroup bt = new ButtonGroup();
		bt.add(chckbxAvviaNodoE);
		bt.add(chckbxAvviaNodo);
		
		btnStartNode = new JButton("Start Node");
		
		btnStartNode.setBounds(383, 179, 117, 29);
		frame.getContentPane().add(btnStartNode);
		
		fileChooser = new JFileChooser();
		
		
		textField_file = new JTextField();
		textField_file.setBounds(199, 107, 172, 28);
		frame.getContentPane().add(textField_file);
		textField_file.setColumns(10);
		
		JLabel lblFileDiConfigurazione = new JLabel("File di configurazione:");
		lblFileDiConfigurazione.setBounds(43, 113, 144, 16);
		frame.getContentPane().add(lblFileDiConfigurazione);
		
		 btnSelezionaFile = new JButton("Seleziona file");
		btnSelezionaFile.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				
				 fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
				  if(fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){
		              textField_file.setText(String.valueOf(fileChooser.getSelectedFile()));
		      }
			}
		});
		btnSelezionaFile.setBounds(383, 108, 117, 29);
		frame.getContentPane().add(btnSelezionaFile);
		
		
		
	}

}
